<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head>
	<#include "${request.contextPath}/common/head.ftl"/>

</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="defaultForm" action="${ctx}/websiteconfig/studentMien/add" method="post"
              onsubmit="return false;">



                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片：</label>
                            <div class="col-sm-10">
                                <div class="input-group">
                                    <input  id="imageUrl" name="imageUrl"  type="text" class="form-control"  style="background-color: #fff;" readonly>
                                    <span class="input-group-btn">
                                            <button type="button" class="btn btn-primary " id="selectImage"  data-toggle="modal" data-target="#selectImageModal">上传图片</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">PDF：</label>
                            <div class="col-sm-10">
                                <div class="input-group">
                                    <input  id="pdfUrl" name="pdfUrl"  type="text" class="form-control"  style="background-color: #fff;" readonly>
                                    <span class="input-group-btn">
                                            <button type="button" class="btn btn-primary" id="selectPdf"  data-toggle="modal" data-target="#selectPdfModal">上传文件</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">视频：</label>
                            <div class="col-sm-10">
                                <div class="input-group">
                                    <input  id="videoUrl" name="videoUrl"  type="text" class="form-control"  style="background-color: #fff;" readonly>
                                    <span class="input-group-btn">
                                            <button type="button" class="btn btn-primary" id="selectVideo"  data-toggle="modal" data-target="#selectVideoModal">上传文件</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
                <a class="btn btn-success" onclick="testOpenWindow()">
                    <i class="fa fa-plus"></i> 上传图片
                </a>
            </div>

		</form>
	</div>

	<#include "${request.contextPath}/common/footer.ftl"/>
	<script src="${ctx}/static/ajax/libs/select/select2.js"></script>
    <script src="${ctx}/static/js/plugins/datePicker/WdatePicker.js"></script>
    <script src="${ctx}/static/js/tookeen.js"></script>
	<script>



        $("#defaultForm").validate({
        	rules:{
                name:{
        			required:true
        		},
                detailAddress:{
                    required:true
                }
        	},
        	messages: {
                "name": {
                    remote: "姓名不能为空"
                },
        		"detailAddress":{
                	remote: "地址不能为空"
        		}
            }
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
                $("#defaultForm").ajaxSubmit(function (data) {
                    $.operate.saveSuccess(data);
                });
	        }

	    }


        $(document).ready(function () {
            $("#selectImage").click(function () {
                openButtonWindow("上传图片", ctx + '/fileUpload/toUploadImage', 600, 400, '完成',setImageUrl);
            });
            $("#selectPdf").click(function () {
                openButtonWindow("上传文件", ctx + '/fileUpload/toUploadPdf', 600, 400, '完成',setPdfUrl);
            });
            $("#selectVideo").click(function () {
                openButtonWindow("上传视频", ctx + '/fileUpload/toUploadVideo', 600, 400, '完成',setVideoUrl);
            });


        });

        function setImageUrl() {
            var imageUrl = $("#imageUrl").val();
            if(localStorage.imageUrl){
                if(imageUrl){
                    imageUrl += ","+localStorage.imageUrl;
                }else{
                    imageUrl= localStorage.imageUrl;
                }
                $("#imageUrl").val(imageUrl);
                localStorage.removeItem("imageUrl");
            }
        }

        function setPdfUrl() {

            var pdfUrl = $("#pdfUrl").val();
            if(localStorage.pdfUrl){
                if(pdfUrl){
                    pdfUrl += ","+localStorage.pdfUrl;
                }else{
                    pdfUrl= localStorage.pdfUrl;
                }
                $("#pdfUrl").val(pdfUrl);
                localStorage.removeItem("pdfUrl");
            }

        }

        function setVideoUrl() {

            var videoUrl = $("#videoUrl").val();
            if(localStorage.videoUrl){
                if(videoUrl){
                    videoUrl += ","+localStorage.videoUrl;
                }else{
                    videoUrl= localStorage.videoUrl;
                }
                $("#videoUrl").val(videoUrl);
                localStorage.removeItem("videoUrl");

            }
        }


        function  testOpenWindow(){
            $.modal.open("上传图片", "/uploadTest/");
        }



    </script>
</body>
</html>
